<?php if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Mother_meter_model extends CI_Model {
	public function __construct() {
		parent::__construct();
	}


	public function insert_mom_meter($data){
        $this->db->query("call ubs_mother_meter_ins(?,?,?,?,?,?,?,?,@err,@msg)",$data);
        $que = $this->db->query("SELECT @err as error , @msg as msg");
        echo json_encode($que->result());
    }

    public function update_mom_meter($data){
        $this->db->query("call ubs_mother_meter_upd(?,?,?,?,?,?,?,?,?,@err,@msg)",$data);
        $que = $this->db->query("SELECT @err as error , @msg as msg");
        echo json_encode($que->result());
    }

    public function search_mom($name){
    	$sql = "SELECT * FROM ubs_mother_meter where mother_name LIKE '".$name."' ";

    	$query = $this->db->query($sql);
        if($query->num_rows() != 0){
            return $query->result();
        }
        else {
            $result = "No results found.";
            return $result;
        }
    }

    public function search_momID($id){
    	$sql = "SELECT * FROM ubs_mother_meter where mmeter_id = ".$id." ";
    	$query = $this->db->query($sql);
    	return $query->result();
    }

}